<template>
  <div class="footer">
    <div class="footerBottom">
      <div class="about">
        <a class="footerNav" @click="goOthers('foundReason')">创办缘由</a>
        <a class="footerNav" @click="goOthers('useState')">使用声明</a>
        <a class="footerNav" @click="goOthers('policySupport')">政策支持</a>
        <a class="footerNav" @click="goOthers('copyrightState')">版权声明</a>
        <!-- <a class="footerNav">联系方式</a> -->
        <a class="footerNav" @click="goFeedback">内容纠错</a>
      </div>
      <div class="permit">
        <a>@版权所有 网站备案许可</a>
      </div>
      <div class="dataDownload">
        <span>资料下载：</span>
        <a @click="download('健康中国行动纲领')">健康中国行动纲领</a>
        <a @click="download('全民健康宣传手册')">全民健康宣传手册</a>
      </div>
    </div>
  </div>
</template>

<script>
import {Message} from 'element-ui'
export default {
  name: "Footer",
  methods:{
    goOthers(path){
      let link = this.$router.resolve({
        path: `/${path}`,
      });
      window.open(link.href, "_blank");
    },
    goFeedback(){
      if (this.$cookies.get(this.$api.TOKENKEY)) {
        let link = this.$router.resolve({
          path: "/feedback",
        });
        window.open(link.href, "_blank");
      } else {
        Message({
          message: "未登录或者登录状态已过期，清重新登录",
          type: "error",
          duration: 1000,
        });
      }
    },
    async download(fileName) {
      let listRes = await this.$api.searchManualList();
      if (listRes.code === 200) {
        if (listRes.rows.length >= 1) {
          let res = await this.$api.downloadByFile(fileName);
          if (res.code === 200) {
            if (res.total === 0) {
              Message({
                message: "文件丢失了，请联系工作人员",
                type: "error",
                duration: 1000,
              });
            } else {
              // let location = this.$api.BASEURL + res.rows[0].manualLocation;
              let list = res.rows[0].manualLocation.split(",");
              for (let item of list) {
                let location = this.$api.BASEURL + item;
                // console.log("location", location);
                window.open(location, "_blank");
              }
              // window.open(location, "_blank");
            }
          }
          // console.log(res);
        }
      }
    },
  }
};
</script>

<style scoped lang="less">
.footer {
  .footerBottom {
    background-color: #f9f9f9;
    padding-bottom: 40px;
    .about {
      padding-top: 20px;
      .footerNav {
        font-size: 14px;
        margin-right: 10px;
        cursor: pointer;
        &:hover {
          color: @themeColor;
        }
      }
    }

    .permit {
      margin-top: 10px;
      font-size: 14px;
      a {
        cursor: pointer;
        &:hover {
          color: @themeColor;
        }
      }
    }

    .dataDownload {
      margin-top: 10px;
      font-size: 14px;
      a {
        color: @themeColor;
        margin-left: 10px;
        cursor: pointer;
      }
    }
  }
}
</style>
